home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
ramswap.arj
/
RAMSWAP.INT
< prev
next >
Wrap
Text File
|
1994-01-26
|
6KB
|
123 lines
The Following is the interface section of the ramswap unit.
UNIT RAMSWAP;
INTERFACE
USES dos;
PROCEDURE SwapExec(ProgramName : PathStr; Parameters : String);
BEGIN
{ Executes Program Name with command line arguments in Parameters. }
{ Implements a search of the DOS PATH for ProgramName if it does }
{ not exist in the current directory. If an extension is not given }
{ it searches for a .COM file first, then an .EXE file then a .BAT }
{ file. (the same order used by COMMAND.COM) This procedure will }
{ execute slightly faster if you supply it with the complete path to}
{ the executable file, in the variable ProgramName. }
{.BAT files have slightly less memory to work with because a secondary}
{copy of COMMAND.COM is loaded to execute them. .COM and .EXE files }
{ are executed without loading a 2nd copy of COMMAND.COM to RAM}
{ **** Very Important **** }
{ *IF IT IS SUCCESSFUL THIS PROCEDURE DOES NOT RETURN*
{ This procedure only returns if the program file is not found. }
{ If it successfully executes your program will terminate comp- }
( letely. Any Exit procedures that have been chained will exec.}
{ The RamSwap.COM file will then gain control and actually exec-}
{ cute the child program. It will then restart your program }
{ after the child terminates. It will pass on as much info }
{ as MS-DOS gives about program termination of the Child. }
{ Your program will be restarting at it's first BEGIN statement }
{ in it's units initialization code or the main module. }
{ their are several functions in this unit to help you design }
{ your program logic to take advantage of this information. }
END.
PROCEDURE ReadStorage(Var Target; TargetSize : Word);
BEGIN
{ a little over half of RAMSWAP.COM's memory usage is actual }
{ program code. Almost half of it is a 1024 byte buffer which }
{ you can use to hold over data in RAM from a call to SWAPEXEC }
{ to the reexecution of your program. Read Storage should be }
{ called to read this buffer into a RECORD structure in your }
{ program. Attempts to read greater than 1024 bytes will gen- }
{ erate an error and the program will halt. }
{ Bounds checking is not done Target should be at least }
{ TargetSize Bytes in size or adjacent memory will be over written }
END;
PROCEDURE StoreData(Var Source; SourceSize : Word);
BEGIN
{ DITTO above. Should be called before SwapExec to store any data }
{ you want to hold over from one call to the next. All other variables }
{ will be lost because your program will terminate. 1024 byte limit }
{ applies. }
{ HINT: If you save EMS or XMS allocation information in this buffer }
{ your application does not have to reallocate that type of memory }
{ when it restarts. (unless you are using a unit type interface, }
{ that you did not write that automatically frees that memory on }
{ exit) }
{ a lot of data can be held in this manner. }
{ if I can get enough interest generated I might be inclined to }
{ include support for that feature in this unit or in a seperate }
{ unit designed to work with this. }
END;
PROCEDURE SwapEnd;
BEGIN
{ Since RAMSWAP.COM is in control of your application a standard HALT }
{ or exiting at the END. in your main program file will just put you }
{ in an infinite loop. Call SwapEnd when you really want to quit. }
{ ** FLASH I'm giving you some source code.}
{ If you don't want to call SwapEnd. just put the statement HALT(17) }
{ where you want to end your program execution. }
END;
FUNCTION Child_Had_Error : BOOLEAN;
BEGIN
{Returns TRUE if DOS encountered an error while executing the last
child program from RAMSWAP.COM}
END;
FUNCTION SwapChildDosError : INTEGER;
BEGIN
{If Child_Had_Error then SwapChildDosError will return the
standard DOS error code encountered. If Child_Had_Error returns
FALSE this function returns a -1}
END;
FUNCTION SwapChildExitCode : INTEGER;
BEGIN
{ If DOS didn't encounter an error then SwapChildExitCode will
return the Exit code of the last process executed by RAMSWAP.
if an error was encountered returns a -1}
END;
FUNCTION IsFirstPass : BOOLEAN;
BEGIN
{ This function is very important when developing using RAMSWAP.COM
since program flow will not follow the conventional path this
function should be called very near the start of your program.
It will tell the program wheather or not This is the first time
it has been loaded (IsFirstPass = TRUE) or if it is being reexecuted
after a child process has terminated (IsFirstPass=FALSE)
This should indicate to the program that it has information to
retrieve from the storage buffer *SEE ReadStorage ABOVE* that it
can use to make a decision on it's next action.};
END;
FUNCTION SwapModulePresent : BOOLEAN;
BEGIN
{ This tells your program is RAMSWAP.COM is resident in memory }
{ returns FALSE if RAMSWAP.COM is not. }
{ you don't really need to call this though because the RAMSWAP}
{ unit terminates the program with an error message if it was }
{ not loaded from the RAMSWAP.COM swap driver. }
END.